

let ajaxTime = 0;
const baseURL = 'http://157.122.54.189:9088';
export default (params) => {
  ajaxTime++;
  uni.showLoading({
    title: '加载中',
    mask: true
  })

  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      url: baseURL + params.url,
      success(res) {

        if (res.data.code) {

          uni.showToast({
            title: res.data.msg,
            icon: 'none'
          })
        } else {
          resolve(res.data)
        }

      },
      fail(err) {
        reject(err)
      },
      complete() {
        ajaxTime--;
        if (!ajaxTime) {
          uni.hideLoading()
        }
      }
    })
  })
}